<?php
/**
 * 用户订单管理
 */
namespace V3\Controller;

use Think\Controller;

class OrderController extends ApiCommonController
{
	
	//提交单个商品
	    public function addorder()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['modified_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));			
		$o=M('Order')
		$od = M('Orderdetial');
		
		$re=$o->add($data);
		if($re){
				$datadetial['order_id']= $r['id'];
				$datadetial['user_id']= $r['user_id'];
				$datadetial['product_id']=trim(I('post.product_id'));
			    $datadetial['product_brand']=trim(I('post.product_brand'));
				$datadetial['product_title']=trim(I('post.product_title'));
				$datadetial['product_desc']=trim(I('post.product_desc'));
				$datadetial['product_img']=trim(I('post.product_img'));
				$datadetial['product_price']=trim(I('post.product_price'));
				$datadetial['product_cprice']=trim(I('post.product_cprice'));
				$datadetial['product_count']=trim(I('post.product_count'));
				$datadetial['product_kc']=trim(I('post.product_kc'));
				$datadetial['jxs_id']=trim(I('post.jxs_id'));
				$datadetial['jxs_title']=trim(I('post.jxs_title'));
				$datadetial['product_color']=trim(I('post.product_color'));
				$datadetial['product_guige']=trim(I('post.product_guige'));
				$datadetial['created_time']=time();
				$datadetial['modified_time']=time();
				$redata=$od->add($datadetial);
				if($redata){
		               $return_data['status']='1';
		                $return_data['info']='成功!';
		        }else{
		                $return_data['status']='2';
		                $return_data['info']='失败!';
            }
		}else{
		                $return_data['status']='2';
		                $return_data['info']='失败!';
            }
			
  		$this->ajaxReturn($return_data);
		 
		 
    }
	//提交购物车商品
		    public function addcart()
    {	
      	
		$data['cart_id']=trim(I('post.cart_id'));
		$o=M('Order')
		$od = M('Orderdetial');
		$c = M('Cart');
		
		$cd=$c->where('id='.$data['cart_id'])->select();
		if($cd){
				$data['user_id']= $cd['user_id'];
			 	$data['code']=trim(I('post.code'));
			    $data['created_time']=time();
				$data['modified_time']=time();
				$data['code_money']=trim(I('post.code_money'));		
				$data['r_username']=trim(I('post.r_username'));
				$data['r_phone']=trim(I('post.r_phone'));
				$data['r_addr']=trim(I('post.r_addr'));
				$re=$o->add($data);					
			}else{
				$return_data['status']='2';
		        $return_data['info']='失败!';
			}
		if($re){
				$datadetial['order_id']= $r['id'];
				$datadetial['user_id']= $cd['user_id'];
				$datadetial['product_id']=$cd['product_id'];
			    $datadetial['product_brand']=$cd['product_brand'];
				$datadetial['product_title']=$cd['product_title'];
				$datadetial['product_desc']=$cd['product_desc'];
				$datadetial['product_img']=$cd['product_img'];
				$datadetial['product_price']=$cd['product_price'];
				$datadetial['product_cprice']=$cd['product_cprice'];
				$datadetial['product_count']=$cd['product_count'];
				$datadetial['product_kc']=$cd['product_kc'];
				$datadetial['jxs_id']=$cd['jxs_id'];
				$datadetial['jxs_title']=$cd['jxs_title'];
				$datadetial['product_color']=$cd['product_color'];
				$datadetial['product_guige']=$cd['product_guige'];
				$datadetial['created_time']=time();
				$datadetial['modified_time']=time();
				
				$redata=$od->add($datadetial);
				if($redata){
		               $return_data['status']='1';
		                $return_data['info']='成功!';
		        }else{
		                $return_data['status']='2';
		                $return_data['info']='失败!';
            }	
			
		}else{
		                $return_data['status']='2';
		                $return_data['info']='失败!';
            }
		
	 	$this->ajaxReturn($return_data);
		 
    }
		//查看订单列表
		    public function getorder()
    {	
      	$user_id=trim(I('get.user_id'));
	    
		if($user_id){
		$re=M('Order')->where('user_id='.$user_id)->select();
				if($re){
		               $return_data['status']='1';
		                $return_data['info']='成功!';
		        }else{
		                $return_data['status']='2';
		                $return_data['info']='失败!';
            }	
		}else{
			$return_data['status']='2';
		    $return_data['info']='失败!';
		}

		 	$this->ajaxReturn($return_data);
		 
    }
	//查看订单详情
		    public function getorderdetial()
    {	
      		$order_id=trim(I('get.id'));
	    
		if($order_id){
		$re=M('Orderdetial')->where('order_id='.$order_id)->select();
				if($re){
		               $return_data['status']='1';
		                $return_data['info']='成功!';
		        }else{
		                $return_data['status']='2';
		                $return_data['info']='失败!';
            }	
		}else{
			$return_data['status']='2';
		    $return_data['info']='失败!';
		}

		 	$this->ajaxReturn($return_data);
		 
		 
    }

	//修改收件信息
		    public function editr()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));
		
	    $data['product_id']=trim(I('post.user_id'));
	    $data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
			

		 
		 
    }
		
		
	//取消订单
		    public function editorder()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));
		
	    $data['product_id']=trim(I('post.user_id'));
	    $data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
			

		 
		 
    }


	//延长收货
		    public function editr()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));
		
	    $data['product_id']=trim(I('post.user_id'));
	    $data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
			

		 
		 
    }
	
	
	//退货/退款
		    public function editr()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));
		
	    $data['product_id']=trim(I('post.user_id'));
	    $data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
			

		 
		 
    }
	//默认收货
		    public function editr()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));
		
	    $data['product_id']=trim(I('post.user_id'));
	    $data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
			

		 
		 
    }
		//删除订单
		    public function editr()
    {	
      	$data['user_id']=trim(I('post.user_id'));
	    $data['code']=trim(I('post.code'));
	    $data['created_time']=time();
		$data['code_money']=trim(I('post.code_money'));		
		$data['r_username']=trim(I('post.r_username'));
		$data['r_phone']=trim(I('post.r_phone'));
		$data['r_addr']=trim(I('post.r_addr'));
		
	    $data['product_id']=trim(I('post.user_id'));
	    $data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
		$data['product_id']=trim(I('post.user_id'));
			

		 
		 
    }

		
		
		
	
}
